home *** CD-ROM | disk | FTP | other *** search
- on ChangeState whichObject
- global gObjStateList
- set thisObj to getaProp(gObjStateList, whichObject)
- set myStateCount to item 2 of thisObj
- set newState to item 1 of thisObj + 1
- if newState > myStateCount then
- set newState to 1
- end if
- put integer(newState) into item 1 of thisObj
- setaProp(gObjStateList, whichObject, thisObj)
- end
-
- on ReverseState whichObject
- global gObjStateList
- set thisObj to getaProp(gObjStateList, whichObject)
- set myStateCount to item 2 of thisObj
- set newState to item 1 of thisObj - 1
- if newState < 1 then
- set newState to myStateCount
- end if
- put integer(newState) into item 1 of thisObj
- setaProp(gObjStateList, whichObject, thisObj)
- end
-
- on SetState whichObject, newState
- global gObjStateList
- set thisObj to getaProp(gObjStateList, whichObject)
- put integer(newState) into item 1 of thisObj
- setaProp(gObjStateList, whichObject, thisObj)
- end
-
- on TestObjStates whichObject, whichCond
- global gObjStateList
- set thisObj to getaProp(gObjStateList, whichObject)
- set me to 0
- if voidp(thisObj) then
- beep()
- beep()
- beep()
- put whichObject, whichCond
- else
- if item 1 of thisObj = whichCond then
- set me to 1
- end if
- end if
- return me
- end
-
- on CheckState whichObject
- global gObjStateList
- set thisObj to getaProp(gObjStateList, whichObject)
- if voidp(thisObj) then
- beep()
- beep()
- beep()
- put whichObject
- else
- set me to item 1 of thisObj
- end if
- return me
- end
-
- on GetBaseItem whichObject
- set done to 0
- set the itemDelimiter to "_"
- if the number of items in whichObject = 2 then
- delete char -30002 of whichObject
- end if
- set the itemDelimiter to ","
- return whichObject
- end
-
- on Dash2UnderScore what
- repeat with count = 1 to the number of chars in what
- if char count of what = "-" then
- put "_" into char count of what
- end if
- end repeat
- return what
- end
-
- on AddToInv whichItem
- global cHUDSprite, gBorgInv, gTakenInv, gInvData, gInvArmState, cLayerSoundSprite, gMixSound, gLastSound, gBorgWeapons, cDragSprite, gCardName, gItemField, gItemCount
- spriteBox(cDragSprite, 0, 500, 1, 501)
- myPlaySound("Take Sound")
- set the itemDelimiter to "\"
- repeat with thisLine = 1 to the number of lines in field "Card Index"
- if item 2 of line thisLine of field "Card Index" = whichItem then
- set thisInfo to line thisLine of field "Card Index"
- exit repeat
- end if
- end repeat
- set invType to item 14 of thisInfo
- set the itemDelimiter to ","
- if invType = "W" then
- if gBorgWeapons = EMPTY then
- put whichItem after gBorgWeapons
- else
- put "," & whichItem after gBorgWeapons
- end if
- else
- if gBorgInv = EMPTY then
- put whichItem after gBorgInv
- else
- put "," & whichItem after gBorgInv
- end if
- end if
- if gInvData = EMPTY then
- put thisInfo after gInvData
- else
- put RETURN & thisInfo after gInvData
- end if
- if gTakenInv = EMPTY then
- put whichItem after gTakenInv
- else
- put "," & whichItem after gTakenInv
- end if
- if gInvArmState = 1 then
- ShowInvArm()
- end if
- end
-
- on RemoveInv whichItem
- global gBorgInv, gTakenInv, gInvData
- set thisObject to GetBaseItem(whichItem)
- if the last char in thisObject <> "*" then
- repeat with thisLine = 1 to the number of lines in gInvData
- if item 2 of line thisLine of gInvData = whichItem then
- delete line thisLine of gInvData
- exit repeat
- end if
- end repeat
- repeat with thisItem = 1 to the number of items in gBorgInv
- if item thisItem of gBorgInv = whichItem then
- delete item thisItem of gBorgInv
- exit repeat
- end if
- end repeat
- repeat with thisItem = 1 to the number of items in gInvData
- if item thisItem of gInvData = whichItem then
- delete item thisItem of gInvData
- exit repeat
- end if
- end repeat
- end if
- end
-
- on CheckInInv whichItem
- global gBorgInv, gTakenInv, gInvData
- set inINV to 0
- repeat with thisItem = 1 to the number of items in gBorgInv
- if item thisItem of gBorgInv = whichItem then
- set inINV to 1
- exit repeat
- end if
- end repeat
- return inINV
- end
-
- on buildCastIndex
- global myCast
- set myCast to [:]
- set done to 0
- set thisCast to 0
- repeat with thisCast = 1 to the number of castMembers
- if the name of cast thisCast <> 0 then
- set myCastName to the name of cast thisCast
- addProp(myCast, myCastName, thisCast)
- end if
- end repeat
- sort(myCast)
- end
-
- on myPlaySound whichSound
- global gLastSound, gMixSound, cLayerSoundSprite, cBackSoundSprite, myCast
- if gMixSound then
- sound stop cLayerSoundSprite
- updateStage()
- set thisSound to getaProp(myCast, whichSound)
- if the preLoad of cast thisSound = 0 then
- preLoadCast(thisSound)
- end if
- puppetSound(cLayerSoundSprite, thisSound)
- updateStage()
- else
- sound stop 1
- updateStage()
- puppetSound(whichSound)
- updateStage()
- repeat while soundBusy(1)
- nothing()
- end repeat
- if gLastSound <> EMPTY then
- sound stop 1
- updateStage()
- puppetSound(gLastSound)
- end if
- end if
- end
-
- on FindSprite whichObject
- global cMaxRegions, cSiteFirstRegion, gCurrentSite
- set myTestString to whichObject & "_" & GetBaseSite(gCurrentSite) & "_" & CheckState(whichObject)
- set theSpriteReturn to 0
- repeat with count = cSiteFirstRegion to cMaxRegions + cSiteFirstRegion - 1
- set thisCastName to the name of cast the castNum of sprite count
- set temp to offset(myTestString, thisCastName)
- if temp > 0 then
- set theSpriteReturn to count
- exit repeat
- end if
- end repeat
- return theSpriteReturn
- end
-
- on idle
- global gLastTime, gEnvDamage, gLastFire
- if the timer > (gLastTime + 60) then
- ProcessDamage(gEnvDamage)
- set gLastTime to the timer
- end if
- UpdateHUDWeapon()
- end
-
- on UpdatePalettes
- global gPaletteList, gPalIndex, gCurrentPalette, gBrightness, gWorldPalette, gBrightAdjust, cBrightMax, cBrightMin
- set PalCount to the number of items in gPaletteList
- set gPalIndex to gPalIndex + 1
- if gPalIndex > PalCount then
- set gPalIndex to 1
- end if
- set thisPalette to item gPalIndex of gPaletteList
- if thisPalette = "WPal" then
- set thisPalette to gWorldPalette
- end if
- set currentBrightness to gBrightAdjust + gBrightness
- if currentBrightness > cBrightMax then
- set currentBrightness to cBrightMax
- end if
- if currentBrightness < cBrightMin then
- set currentBrightness to cBrightMin
- end if
- put "_" & currentBrightness after thisPalette
- if thisPalette <> gCurrentPalette then
- puppetPalette(thisPalette, 29, 0)
- set gCurrentPalette to thisPalette
- end if
- end
-
- on UpdateEnv
- global gCurrentEnv, cBackSoundSprite, gCurrentSite, gPaletteList, gPalIndex, gCurrentPalette, gWorldPalette, cBrightMax, cBrightMin, gBrightness, gBrightAdjust, gMixSound, gLastSound, gEnvDamage, gFightMode, gWarningTime
- set cEnvSite to 1
- set cEnvType to 2
- if (the ticks - gWarningTime) > 600 then
- updateWarning("Warning-None")
- end if
- set envCount to the number of items in gCurrentEnv
- repeat with thisEnv = 1 to envCount
- if item cEnvSite of line thisEnv of gCurrentEnv = gCurrentSite then
- if item cEnvType of line thisEnv of gCurrentEnv = "F" then
- set newValue to item 3 of line thisEnv of gCurrentEnv
- if newValue = "TRUE" then
- set gFightMode to 1
- end if
- if newValue = "FALSE" then
- set gFightMode to 0
- end if
- end if
- if item cEnvType of line thisEnv of gCurrentEnv = "BS" then
- set whichSound to item 3 of line thisEnv of gCurrentEnv
- if whichSound = EMPTY then
- if gMixSound then
- puppetSound(0)
- set gLastSound to EMPTY
- else
- puppetSound(0)
- set gLastSound to EMPTY
- end if
- set gLastSound to whichSound
- else
- if gLastSound <> whichSound then
- if gMixSound then
- puppetSound(whichSound)
- set gLastSound to whichSound
- else
- puppetSound(whichSound)
- set gLastSound to EMPTY
- end if
- end if
- end if
- end if
- if item cEnvType of line thisEnv of gCurrentEnv = "P" then
- if the number of items in line thisEnv of gCurrentEnv = 3 then
- set gPaletteList to item 3 of line thisEnv of gCurrentEnv
- else
- set gPaletteList to line thisEnv of gCurrentEnv
- delete item 1 to 2 of gPaletteList
- end if
- end if
- if item cEnvType of line thisEnv of gCurrentEnv = "BA" then
- set gBrightAdjust to value(item 3 of line thisEnv of gCurrentEnv)
- end if
- if item cEnvType of line thisEnv of gCurrentEnv = "BC" then
- set gBrightness to value(item 3 of line thisEnv of gCurrentEnv)
- end if
- if item cEnvType of line thisEnv of gCurrentEnv = "SP" then
- set thisScript to value(item 3 of line thisEnv of gCurrentEnv)
- do(thisScript)
- end if
- if item cEnvType of line thisEnv of gCurrentEnv = "DM" then
- set gEnvDamage to item 3 to 8 of line thisEnv of gCurrentEnv
- end if
- end if
- end repeat
- end
-
- on ImportNewWorldCast
- if the commandDown then
- set fileObj to FileIO(mnew, "?read", "PICT")
- if fileObj < 0 then
- beep()
- else
- set saveCount to 0
- set ImportPath to fileObj(mFileName)
- put fileObj(mdispose)
- set the itemDelimiter to ":"
- set itemCount to the number of items in ImportPath
- delete item itemCount of ImportPath
- set the itemDelimiter to ","
- put ":" after ImportPath
- set lastCast to findEmptyCast()
- repeat with count = 101 to lastCast - 1
- duplicate(cast 10, cast count)
- end repeat
- set theFiles to []
- set theFiles to GetFileList(ImportPath)
- set fileCount to the number of lines in theFiles
- repeat with count = 1 to fileCount
- set saveCount to saveCount + 1
- set thisFile to line count of theFiles
- set thisFile to ImportPath & thisFile
- importCast(thisFile)
- if saveCount > 10 then
- saveMovie()
- set saveCount to 0
- end if
- end repeat
- saveMovie()
- end if
- end if
- end
-
- on GetRegions whichSite
- global gClickRegionIndex, gClickRegions
- set myRegions to EMPTY
- set firstRegionIndex to value(getaProp(gClickRegionIndex, whichSite))
- repeat with count = firstRegionIndex to the number of lines in gClickRegions
- if item 1 of line count of gClickRegions = whichSite then
- if item 1 of line count of gClickRegions = whichSite then
- put line count of gClickRegions & RETURN after myRegions
- end if
- next repeat
- end if
- exit repeat
- end repeat
- if myRegions <> EMPTY then
- delete line the number of lines in myRegions of myRegions
- end if
- return myRegions
- end
-
- on GetEnviro whichSite
- global gEnvStates, gEnvIndex
- set myEnviroTable to EMPTY
- set firstEnvIndex to value(getaProp(gEnvIndex, whichSite))
- repeat with count = firstEnvIndex to the number of lines in gEnvStates
- if item 1 of line count of gEnvStates = whichSite then
- if item 1 of line count of gEnvStates = whichSite then
- put line count of gEnvStates & RETURN after myEnviroTable
- end if
- next repeat
- end if
- exit repeat
- end repeat
- if myEnviroTable <> EMPTY then
- delete line the number of lines in myEnviroTable of myEnviroTable
- end if
- return myEnviroTable
- end
-
- on GetBaseSite whichSite
- set done to 0
- repeat while not done
- set theCharCount to the number of chars in whichSite
- if char theCharCount of whichSite >= "0" then
- if char theCharCount of whichSite <= "9" then
- set whichSite to char 1 to theCharCount - 1 of whichSite
- next repeat
- end if
- set done to 1
- end if
- end repeat
- return whichSite
- end
-
- on ClearPanSites
- global gPanRegions, cMaxRegions, cSiteFirstRegion, cPanFirstRegion
- set cView.Left to 0
- set cView.Top to 0
- set cView.Right to 640
- set cView.Bottom to 390
- spriteBox(cPanView, cView.Left + cView.Right + 1, cView.Top, cView.Right + cView.Right + 1, cView.Bottom)
- set cView.Left to 0
- set cView.Top to 0
- set cView.Right to 640
- set cView.Bottom to 390
- spriteBox(cCurrentView, cView.Left, cView.Top, cView.Right, cView.Bottom)
- repeat with count = 1 to cMaxRegions
- set thisSprite to count + cPanFirstRegion - 1
- puppetSprite(thisSprite, 1)
- spriteBox(thisSprite, 0, 500, 1, 501)
- end repeat
- end
-
- on CheckAltSites whichSite
- global gCurrentSite, gStateTable, gStateTableIndex
- set me to whichSite
- set whichSite to GetBaseSite(whichSite)
- set firstObjIndex to value(getaProp(gStateTableIndex, whichSite))
- set myObjTable to EMPTY
- repeat with count = firstObjIndex to the number of lines in gStateTable
- if item 1 of line count of gStateTable = whichSite then
- if item 1 of line count of gStateTable = whichSite then
- put line count of gStateTable & RETURN after myObjTable
- end if
- next repeat
- end if
- exit repeat
- end repeat
- if myObjTable <> EMPTY then
- delete line the number of lines in myObjTable of myObjTable
- else
- set gCurrentSite to me
- return me
- exit
- end if
- set StateCount to the number of lines in myObjTable
- repeat with thisItem = 1 to StateCount
- if item 1 of line thisItem of myObjTable = whichSite then
- set SiteStateCount to item 3 of line thisItem of myObjTable
- set theResult to 0
- repeat with thisState = 1 to SiteStateCount
- set whichObj to item (2 * (thisState - 1)) + 4 of line thisItem of myObjTable
- set whichCond to item (2 * (thisState - 1)) + 5 of line thisItem of myObjTable
- set theResult to value(TestObjStates(whichObj, whichCond)) + theResult
- end repeat
- if theResult = SiteStateCount then
- set me to item 2 of line thisItem of myObjTable
- set thisItem to 100
- end if
- end if
- end repeat
- set gCurrentSite to me
- return me
- end
-
- on StoreCleanUpSpriteUsage
- global cMaxRegions, cPanFirstRegion, cArmSprite, cArmSpriteMax
- put the freeBytes
- repeat with thisSprite = cPanFirstRegion to cPanFirstRegion + cMaxRegions - 1
- set killCastNum to the castNum of sprite thisSprite
- unLoadCast(killCastNum)
- end repeat
- repeat with thisSprite = cArmSprite to cArmSprite + cArmSpriteMax
- set killCastNum to the castNum of sprite thisSprite
- unLoadCast(killCastNum)
- end repeat
- put the freeBytes
- end
-
- on slideSprite snum, endH, endV
- set pixelJump to 5.0
- set maxSteps to 15
- set startH to the locH of sprite snum
- set startV to the locV of sprite snum
- set deltaH to endH - startH
- set deltaV to endV - startV
- if abs(deltaH) > abs(deltaV) then
- set steps to float(abs(deltaH) / pixelJump)
- else
- set steps to float(abs(deltaV) / pixelJump)
- end if
- if steps > maxSteps then
- set steps to maxSteps
- end if
- if abs(steps) > 1 then
- set addH to float(deltaH / steps)
- set addV to float(deltaV / steps)
- repeat with stepCount = 1 to steps
- set the locH of sprite snum to startH + (stepCount * addH)
- set the locV of sprite snum to startV + (stepCount * addV)
- updateStage()
- end repeat
- end if
- set the locH of sprite snum to endH
- set the locV of sprite snum to endV
- updateStage()
- end
-